from selenium import webdriver
import time
from selenium.webdriver.support.ui import Select

class TestCase6:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://news.baidu.com/')
        time.sleep(3)

    def scrollj1(self):
        # 滑动到最后
        js1 = 'window.scrollTo(0,document.body.scrollHeight)'
        self.driver.execute_script(js1)
        time.sleep(2)
        js1 = 'window.scrollTo(0,document.body.scrollHeight)'
        self.driver.execute_script(js1)

        time.sleep(2)
        js2 = 'window.scrollTo({top:0,left:0,behavior:"smooth"})'
        self.driver.execute_script(js2)
        time.sleep(2)

        # 指定元素
        element_hebei = self.driver.find_element_by_xpath('//*[@id="pane-news"]/ul[5]/li[1]/a')
        self.driver.execute_script('arguments[0].scrollIntoView()', element_hebei)

    def quit(self):
        time.sleep(3)
        self.driver.quit()


# if __name__ == '__main__':
    # case6 = TestCase6()
    # case6.scrollj1()
    #
    # case6.quit()

class TextCase5():
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://www.sahitest.com/demo/selectTest.htm')
        time.sleep(1)

    def select2(self):
        s3 = self.driver.find_element_by_id('s3Id')
        select = Select(s3)
        select.select_by_index(3)
        time.sleep(4)s
        select.select_by_value('o2val')
        time.sleep(3)
        select.select_by_visible_text('o1')

    def quit(self):
        time.sleep(2)
        self.driver.quit()
if __name__ == '__main__':
    case5 = TextCase5()
    case5.select2()
    case5.quit()